import { FormEvent } from "miniprogram/@types/Event"
import { Form } from "miniprogram/pages/user/@types/form"

// components/activity-canlendar/activity-canlendar.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    currentMode:"",
    currentModeIndex:-1,
    calendarTypes:["周历","月历","日历"],
    form:{
      calendarType:"周历",
      calendarTypeIndex:0,
      selectSchool:"广东工业大学",
      selectRegion:"大学城",
    },
    schoolRegions:[["广东工业大学","2","3"],["大学城","2","3"]],
    colors:["blue","yellow","lightblue"],
    modes:["学习","交友","娱乐"]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    changeMode(e:FormEvent<{index:number}>){
      const {index}=e.currentTarget.dataset
      this.setData({
        currentMode:this.data.modes[index],
        currentModeIndex:index
      })
    },
    getDetail:function(e:FormEvent<null>){
     this.setData({
       form:{
        ...this.data.form,
        calendarType:"日历",
        calendarTypeIndex:2
       },
     })
     this.selectComponent("#day-calendar").getDetail(e.detail)
    },
    handleCalendarChange:function(e:FormEvent<null>){
      this.setData({
        form:{
          ...this.data.form,
          calendarType:this.data.calendarTypes[e.detail.value],
          calendarTypeIndex:e.detail.value
        }
      })
    },
    handleLoactionChange(e:FormEvent<null>){
      const [schoolIndex,regionIndex]=e.detail.value
      const {form,schoolRegions}=this.data
      this.setData({
        form:{
          ...form,
          selectSchool:schoolRegions[0][schoolIndex],
          selectRegion:schoolRegions[1][regionIndex]
        }
      })
    },
    createActivity:function(){
      wx.navigateTo({
        url:"/pages/activity/create-activity/create-activity"
      })
    },
  }
})